package org.example.m7_17;

import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) {
        int[] arr = {100,4,200,1,3,2};
        System.out.println(new Test2().MLS(arr));
    }
    public int MLS (int[] arr) {
        // write code here
        Arrays.sort(arr);
        int maxCount  = 0;//最大
        int count = 0;//当前
        int t = 0;
        int l = arr.length;
        for (int i = 0;i < l;i++){
            if ((l - i + count) < maxCount){
                break;
            }
            int num = arr[i];
            if (num == t + 1){
                count++;
            }else {
                if (count > maxCount){
                    maxCount = count;
                }
                count = 1;
            }
            t = num;
        }
        return maxCount;
    }
}
